<template>
	<view class="user-layout pageBg" v-if="userinfo">
		<view class="user-info" :style="{height:getNavFillHeight()+'px'}">
			<view class="avatar">
				<image src="../../static/logo.png" mode="aspectFill"></image>
			</view>
			<view class="ip">{{userinfo.IP}}</view>
			<view class="address">来自于：{{ userinfo.address.city || userinfo.address.province || userinfo.address.country}}</view>
		</view>
		<view class="section">
			<view class="list">
				<navigator url="/pages/class-list/class-list?name=我的下载&type=download" class="row">
					<view class="left">
						<uni-icons type="download-filled" size="25"></uni-icons>
						<text class="text">我的下载</text>
					</view>
					<view class="right">
						<text class="text">{{userinfo.downloadSize}}</text>
						<uni-icons type="right" size="20"></uni-icons>
					</view>
				</navigator>
				<navigator url="/pages/class-list/class-list?name=zs&type=score" class="row">
					<view class="left">
						<uni-icons type="star-filled" size="25"></uni-icons>
						<text class="text">我的评分</text>
					</view>
					<view class="right">
						<text class="text">{{userinfo.scoreSize}}</text>
						<uni-icons type="right" size="20"></uni-icons>
					</view>
				</navigator>
				<navigator url="/pages/class-list/class-list" class="row">
					<view class="left">
						<uni-icons type="contact" size="25"></uni-icons>
						<text class="text">联系客服</text>
					</view>
					<view class="right">
						<text class="text"></text>
						<uni-icons type="right" size="20"></uni-icons>
					</view>
				</navigator>
			</view>
		</view>

		<view class="section">
			<view class="list">
				<navigator url="/pages/class-list/class-list" class="row">
					<view class="left">
						<uni-icons type="download-filled" size="25"></uni-icons>
						<text class="text">订阅更新</text>
					</view>
					<view class="right">
						<text class="text"></text>
						<uni-icons type="right" size="20"></uni-icons>
					</view>
				</navigator>
				<navigator url="/pages/class-list/class-list" class="row">
					<view class="left">
						<uni-icons type="star-filled" size="25"></uni-icons>
						<text class="text">常见问题</text>
					</view>
					<view class="right">
						<text class="text"></text>
						<uni-icons type="right" size="20"></uni-icons>
					</view>
				</navigator>
			</view>
		</view>
	</view>
	<view v-else>
		<view :style="{height:getNavFillHeight()+'px'}"></view>
		<uni-load-more status="loading"></uni-load-more>
	</view>
</template>

<script setup>
	import {
		getNavFillHeight
	} from "@/utils/system.js"
	import {
		apiUserInfo
	} from "@/api/api.js"
	import {
		ref
	} from "vue";

	const userinfo = ref(null)

	const dial = () => {
		uni.makePhoneCall({
			phoneNumber: '114' //仅为示例
		});
	}

	const getUserInfo = () => {
		apiUserInfo().then(res => {
			console.log(res);
			userinfo.value = res.data
		})
	}

	getUserInfo();
	console.log(getNavFillHeight());
</script>

<style lang="scss" scoped>
	.user-layout {
		.user-info {
			display: flex;
			justify-content: center;
			align-items: center;
			flex-direction: column;

			.avatar {
				width: 160rpx;
				height: 160rpx;
				border-radius: 50%;
				overflow: hidden;

				image {
					width: 100%;
					height: 100%;
				}
			}

			.ip {
				font-size: 44rpx;
				padding: 20rpx 0 5rpx;
			}

			.address {
				font-size: 28rpx;
				color: #ababab;
			}
		}

		.section {
			width: 690rpx;
			margin: 50rpx auto;
			box-shadow: 0 0 30rpx rgba(0, 0, 0, 0.05);
			border-radius: 10rpx;

			.row {
				height: 100rpx;
				display: flex;
				justify-content: space-between;
				align-items: center;
				padding: 0 20rpx;
				border-bottom: 1rpx solid #eee;

				.left {
					display: flex;
					justify-content: center;
					align-items: center;

					:deep() {
						.uni-icons {
							color: $brand-theme-color !important;
						}
					}

					.text {
						padding-left: 10rpx;
						color: #888;
						font-size: 30rpx;
					}
				}

				.right {
					display: flex;
					justify-content: center;
					align-items: center;

					:deep() {
						.uni-icons {
							color: $brand-theme-color !important;
						}
					}

					.text {
						color: #999;
						margin-right: 10rpx;
						font-size: 30rpx;
					}
				}

			}

		}
	}
</style>